<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../css/index.css" />
		<script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/vant.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/ajax.js" type="text/javascript" charset="utf-8"></script>
		<script src="html5plus://ready"></script>
		<title></title>
		<style type="text/css">
			body{
				background-color: gainsboro;
			}
			#one {
				background-color: red;
				height: 50px;
			}
			.van-nav-bar__title{
				color: white;
				font-size: 15px;
				padding-top: 5px;
			}
			.van-nav-bar .van-icon{
				color: white;
				
				padding-top: 10px;
			}
			.van-nav-bar__text{
				color: white;
				padding-top: 10px;
			}
			.van-address-list {
			    height: 100%;
			    padding-bottom: 10px;
			    box-sizing: border-box;
			}
			.van-button--small {
			    margin-left: -30px;
			}
			p{
				font-size: 12px;
			}
		</style>
	</head>

	<body>
		<div id="app">
			<van-row >
				<van-nav-bar  title="修改登录密码" left-text="返回" right-text="确认修改" left-arrow id="one" @click-left="onClickLeft" @click-right="onClickRight"></van-nav-bar>
				
			</van-row>
			
			<van-row id="two">
				<van-cell-group>
				  <van-field
				    v-model="sms"
				    center
				    clearable
				    label="短信验证码"
				    placeholder="请输入短信验证码"
				  >
				    <van-button slot="button" size="small" type="primary" @click="yzm">发送验证码</van-button>
				  </van-field>
				</van-cell-group>
				<!--密码-->
				<van-cell-group>
				 
				  <van-field
				    v-model="password"
				    type="password"
				    placeholder="请输入新的密码"
				  />
				</van-cell-group>
				<van-field
				    v-model="rpassword"
				    type="password"
				   size="" placeholder="请确认新的密码"
				  />
				</van-cell-group>
				
			</van-row>
			<p>&copy;系统将会发送短信到你的手机</p>
			
		</div>
		<script type="text/javascript">
			var app = new Vue({
				el: "#app",
				data: {
					
					password:"",
					list:[],
					sms:"",
					rpassword:""
				}
				,
				methods:{
					onClickLeft:function(){
						plus.webview.open("set.html");
					},
					yzm:function(){
						ajax({
							url: "http://dsapi.ysd3g.com/API/SendChangePasswordCode",
							dataType: "jsonp",
							data: {
								key:localStorage.getItem("keys")
							},
							success(res) {
								if (res.Error) {
									app.$toast.fail("发送失败");
								} else{
									app.$toast.success("验证码已发送，请查收");
								app.$toast(res.Code);
								}
							}
						});
					},
					onClickRight:function(){
						if(app.password!=app.rpassword){
							app.$toast.fail("两次密码不一致");
						}else{
							ajax({
							url: "http://dsapi.ysd3g.com/api/ChangePassword",
							dataType: "jsonp",
							data: {
								key:localStorage.getItem("keys"),
								password:app.password,
								phoneCode:app.sms
							},
							success(res) {
								if (res.Error) {
									app.$toast.fail("修改失败");
								} else{
									app.$toast.success("修改成功");
									localStorage.clear();
									plus.webview.getWebviewById("user").reload(false);
									plus.webview.open("sgin.html");
								}
							}
						});
						}
						
					}
				}
			});
		</script>
	</body>

</html>